﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Kugar.Tools.SQLHelper.SQLGenerator.Helpers
{
    public static class ControlExt
    {
        public static IEnumerable<Control> EnumChildControl(this Control parentControl)
        {
            if (parentControl != null)
            {
                yield return parentControl;

                if (parentControl.HasChildren)
                {
                    foreach (var control in parentControl.Controls)
                    {
                        if (control is Control)
                        {
                            foreach (var ctrl in EnumChildControl((Control)control))
                            {
                                yield return ctrl;
                            }
                        }
                    }
                }
            }
            else
            {
                yield break;
            }
        }
    }
}
